home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 1.3 KB | 47 lines |
- [Name]
- Bounce - Allows Sprite to bounce like a ball
- Written by Steve Israelson (modified by Greg Gilman)
-
- [Description]
- The sprite will move and bounce in an area
-
- [Parameters]
- Left edge, BOUNCE_LeftEdge,1
- Right edge, BOUNCE_RightEdge,1
- Top edge, BOUNCE_TopEdge,1
- Bottom edge, BOUNCE_BottomEdge,1
- Speed, BOUNCE_Speed,1,1,10
- Callback, BOUNCE_EVENT,1000
-
- [Frame Loaded] Frame Loaded Handler
- SpriteVars BOUNCE_xvel BOUNCE_yvel
- BOUNCE_xvel = Random(1,$BOUNCE_Speed)
- BOUNCE_yvel = Random(1,$BOUNCE_Speed)
-
- [Idle] Idle Handler
- SpriteVars BOUNCE_xvel BOUNCE_yvel
-
- // Move the sprite
- MoveBy(BOUNCE_xvel, BOUNCE_yvel)
-
- if (BoundsLeft < $BOUNCE_LeftEdge)
- MoveBy(($BOUNCE_LeftEdge - BoundsLeft), 0)
- BOUNCE_xvel = -BOUNCE_xvel;
- ExecuteEvent($BOUNCE_EVENT)
- elseif (BoundsRight > $BOUNCE_RightEdge)
- MoveBy(($BOUNCE_RightEdge - BoundsRight), 0)
- BOUNCE_xvel = -BOUNCE_xvel;
- ExecuteEvent($BOUNCE_EVENT)
- endif
- if (BoundsTop < $BOUNCE_TopEdge)
- MoveBy(($BOUNCE_TopEdge - BoundsTop), 0)
- BOUNCE_yvel = -BOUNCE_yvel;
- ExecuteEvent($BOUNCE_EVENT)
- elseif (BoundsBottom > $BOUNCE_BottomEdge)
- MoveBy(($BOUNCE_BottomEdge - BoundsBottom), 0)
- BOUNCE_yvel = -BOUNCE_yvel;
- ExecuteEvent($BOUNCE_EVENT)
- endif
-
- spritenamed("box").Moveto(spritenamed("tv").firstcornerx + 19, spritenamed("tv").firstcornery + 75)
-